package org.flower.web.servlet;

import com.alibaba.fastjson.JSON;
import com.sun.org.apache.regexp.internal.RE;
import org.flower.bean.CommodityClass;
import org.flower.service.CommodityClassService;
import org.flower.service.impl.CommodityClassServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/manager/getType2ClassIDServlet")
public class getType2ClassIDServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        CommodityClassService classService = new CommodityClassServiceImpl();
        String type1ClassId = request.getParameter("type1ClassId");
        if(type1ClassId!=null&&!type1ClassId.equals("")){
            List<CommodityClass> classByPid = classService.findClassByPid(Integer.parseInt(type1ClassId));
            String s = JSON.toJSONString(classByPid);
            response.getWriter().print(s);
        }else {
            response.getWriter().print("");
        }
    }
}
